package com.jeesite.modules.wxrobot.socketHandle;

import com.jeesite.common.utils.SpringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.HandshakeInterceptor;
import org.springframework.web.socket.server.support.OriginHandshakeInterceptor;

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(myHandler(), "/qrCodeHandler").setAllowedOrigins("*");
       //registry.addHandler(myHandler(), "/qrCodeHandler");
    }

    @Bean
    public WebSocketHandler myHandler() {
       return SpringUtils.getBean(QrCodeWebSocketHandler.class);
        /*return new QrCodeWebSocketHandler();*/
    }

}